3.296 \(\int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx\)

Optimal. Leaf size=76 \[ -\frac {2 \sqrt {a-b} \sqrt {a+b} \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d}-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d} \]

[Out]

-x/a+arctanh(sin(d*x+c))/b/d-2*arctanh((a-b)^(1/2)*tan(1/2*d*x+1/2*c)/(a+b)^(1/2))*(a-b)^(1/2)*(a+b)^(1/2)/a/b
/d

________________________________________________________________________________________

Rubi [A]  time = 0.18, antiderivative size = 76, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 7, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3894, 4051, 3770, 3919, 3831, 2659, 208} \[ -\frac {2 \sqrt {a-b} \sqrt {a+b} \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d}-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d} \]

Antiderivative was successfully verified.

[In]

Int[Tan[c + d*x]^2/(a + b*Sec[c + d*x]),x]

[Out]

-(x/a) + ArcTanh[Sin[c + d*x]]/(b*d) - (2*Sqrt[a - b]*Sqrt[a + b]*ArcTanh[(Sqrt[a - b]*Tan[(c + d*x)/2])/Sqrt[
a + b]])/(a*b*d)

Rule 208

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[-(a/b), 2]*ArcTanh[x/Rt[-(a/b), 2]])/a, x] /; FreeQ[{a,
b}, x] && NegQ[a/b]

Rule 2659

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[(2*e)/d, Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}
, x] && NeQ[a^2 - b^2, 0]

Rule 3770

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3831

Int[csc[(e_.) + (f_.)*(x_)]/(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x_Symbol] :> Dist[1/b, Int[1/(1 + (a*Sin[e
 + f*x])/b), x], x] /; FreeQ[{a, b, e, f}, x] && NeQ[a^2 - b^2, 0]

Rule 3894

Int[cot[(c_.) + (d_.)*(x_)]^2*(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^(n_), x_Symbol] :> Int[(-1 + Csc[c + d*x]
^2)*(a + b*Csc[c + d*x])^n, x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[a^2 - b^2, 0]

Rule 3919

Int[(csc[(e_.) + (f_.)*(x_)]*(d_.) + (c_))/(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x_Symbol] :> Simp[(c*x)/a,
x] - Dist[(b*c - a*d)/a, Int[Csc[e + f*x]/(a + b*Csc[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[
b*c - a*d, 0]

Rule 4051

Int[((A_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))/(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_)), x_Symbol] :> Dist[C/b, I
nt[Csc[e + f*x], x], x] + Dist[1/b, Int[(A*b - a*C*Csc[e + f*x])/(a + b*Csc[e + f*x]), x], x] /; FreeQ[{a, b,
e, f, A, C}, x]

Rubi steps

\begin {align*} \int \frac {\tan ^2(c+d x)}{a+b \sec (c+d x)} \, dx &=\int \frac {-1+\sec ^2(c+d x)}{a+b \sec (c+d x)} \, dx\\ &=\frac {\int \sec (c+d x) \, dx}{b}+\frac {\int \frac {-b-a \sec (c+d x)}{a+b \sec (c+d x)} \, dx}{b}\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\left (\frac {a}{b}-\frac {b}{a}\right ) \int \frac {\sec (c+d x)}{a+b \sec (c+d x)} \, dx\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {\left (\frac {a}{b}-\frac {b}{a}\right ) \int \frac {1}{1+\frac {a \cos (c+d x)}{b}} \, dx}{b}\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {\left (2 \left (\frac {a}{b}-\frac {b}{a}\right )\right ) \operatorname {Subst}\left (\int \frac {1}{1+\frac {a}{b}+\left (1-\frac {a}{b}\right ) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b d}\\ &=-\frac {x}{a}+\frac {\tanh ^{-1}(\sin (c+d x))}{b d}-\frac {2 \sqrt {a-b} \sqrt {a+b} \tanh ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a b d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]  time = 0.15, size = 115, normalized size = 1.51 \[ -\frac {-2 \sqrt {a^2-b^2} \tanh ^{-1}\left (\frac {(b-a) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )+a \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-a \log \left (\sin \left (\frac {1}{2} (c+d x)\right )+\cos \left (\frac {1}{2} (c+d x)\right )\right )+b c+b d x}{a b d} \]

Antiderivative was successfully verified.

[In]

Integrate[Tan[c + d*x]^2/(a + b*Sec[c + d*x]),x]

[Out]

-((b*c + b*d*x - 2*Sqrt[a^2 - b^2]*ArcTanh[((-a + b)*Tan[(c + d*x)/2])/Sqrt[a^2 - b^2]] + a*Log[Cos[(c + d*x)/
2] - Sin[(c + d*x)/2]] - a*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]])/(a*b*d))

________________________________________________________________________________________

fricas [A]  time = 0.55, size = 253, normalized size = 3.33 \[ \left [-\frac {2 \, b d x - a \log \left (\sin \left (d x + c\right ) + 1\right ) + a \log \left (-\sin \left (d x + c\right ) + 1\right ) - \sqrt {a^{2} - b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) - {\left (a^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )} \sin \left (d x + c\right ) + 2 \, a^{2} - b^{2}}{a^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + b^{2}}\right )}{2 \, a b d}, -\frac {2 \, b d x - a \log \left (\sin \left (d x + c\right ) + 1\right ) + a \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, \sqrt {-a^{2} + b^{2}} \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}\right )}{2 \, a b d}\right ] \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2/(a+b*sec(d*x+c)),x, algorithm="fricas")

[Out]

[-1/2*(2*b*d*x - a*log(sin(d*x + c) + 1) + a*log(-sin(d*x + c) + 1) - sqrt(a^2 - b^2)*log((2*a*b*cos(d*x + c)
- (a^2 - 2*b^2)*cos(d*x + c)^2 - 2*sqrt(a^2 - b^2)*(b*cos(d*x + c) + a)*sin(d*x + c) + 2*a^2 - b^2)/(a^2*cos(d
*x + c)^2 + 2*a*b*cos(d*x + c) + b^2)))/(a*b*d), -1/2*(2*b*d*x - a*log(sin(d*x + c) + 1) + a*log(-sin(d*x + c)
 + 1) + 2*sqrt(-a^2 + b^2)*arctan(-sqrt(-a^2 + b^2)*(b*cos(d*x + c) + a)/((a^2 - b^2)*sin(d*x + c))))/(a*b*d)]

________________________________________________________________________________________

giac [B]  time = 1.47, size = 140, normalized size = 1.84 \[ -\frac {\frac {d x + c}{a} - \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right )}{b} + \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right )}{b} + \frac {2 \, {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {-a^{2} + b^{2}}}\right )\right )} {\left (a^{2} - b^{2}\right )}}{\sqrt {-a^{2} + b^{2}} a b}}{d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2/(a+b*sec(d*x+c)),x, algorithm="giac")

[Out]

-((d*x + c)/a - log(abs(tan(1/2*d*x + 1/2*c) + 1))/b + log(abs(tan(1/2*d*x + 1/2*c) - 1))/b + 2*(pi*floor(1/2*
(d*x + c)/pi + 1/2)*sgn(-2*a + 2*b) + arctan(-(a*tan(1/2*d*x + 1/2*c) - b*tan(1/2*d*x + 1/2*c))/sqrt(-a^2 + b^
2)))*(a^2 - b^2)/(sqrt(-a^2 + b^2)*a*b))/d

________________________________________________________________________________________

maple [B]  time = 0.42, size = 153, normalized size = 2.01 \[ -\frac {2 a \arctanh \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{d b \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {2 b \arctanh \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{d a \sqrt {\left (a -b \right ) \left (a +b \right )}}-\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{d b}+\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d b}-\frac {2 \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d a} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(d*x+c)^2/(a+b*sec(d*x+c)),x)

[Out]

-2/d/b*a/((a-b)*(a+b))^(1/2)*arctanh(tan(1/2*d*x+1/2*c)*(a-b)/((a-b)*(a+b))^(1/2))+2/d*b/a/((a-b)*(a+b))^(1/2)
*arctanh(tan(1/2*d*x+1/2*c)*(a-b)/((a-b)*(a+b))^(1/2))-1/d/b*ln(tan(1/2*d*x+1/2*c)-1)+1/d/b*ln(tan(1/2*d*x+1/2
*c)+1)-2/d/a*arctan(tan(1/2*d*x+1/2*c))

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2/(a+b*sec(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*a^2-4*b^2>0)', see `assume?`
 for more details)Is 4*a^2-4*b^2 positive or negative?

________________________________________________________________________________________

mupad [B]  time = 1.63, size = 121, normalized size = 1.59 \[ \frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d}-\frac {2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{a\,d}-\frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a+b\right )}\right )\,\sqrt {a^2-b^2}}{a\,b\,d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(c + d*x)^2/(a + b/cos(c + d*x)),x)

[Out]

(2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/(b*d) - (2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/(a*d)
 - (2*atanh((sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2))/(cos(c/2 + (d*x)/2)*(a + b)))*(a^2 - b^2)^(1/2))/(a*b*d)

________________________________________________________________________________________

sympy [F]  time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\tan ^{2}{\left (c + d x \right )}}{a + b \sec {\left (c + d x \right )}}\, dx \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)**2/(a+b*sec(d*x+c)),x)

[Out]

Integral(tan(c + d*x)**2/(a + b*sec(c + d*x)), x)

________________________________________________________________________________________